using System;
using Entropy.Ext.Ast;

internal class Const : Node
{
	public readonly string Value;

	public Const(object value)
	{
		if (value == null)
			Value = "null";
		else if (value is bool)
			Value = value.ToString().ToLower();
		else if (value is Enum)
			Value = Quote(value.ToString().ToLower());
		else if (value is int || value is decimal || value is double)
			Value = value.ToString();
		else if (value is string)
			Value = Quote((string)value);
		else 
			Value = null;
	}

	internal static string Quote(string s)
	{
		return "'" + s.Replace(Environment.NewLine, "\\") + "'";
	}
}